#!/usr/bin/python3
# -*- coding:utf-8 -*-
""""
   @Author: 叶建伟
   @Email: yejw46507@hundsun.com
   @Time: 2022/6/8 9:36
   @File: 核查场景新增_客户重要信息缺失.py
"""
import re
import time

from 基础公共脚本.步骤检查_hui2 import check_table, check_msg_box, check_tips, check_table_no_exist
from 基础公共脚本.公共方法_hui2 import open_menu, FE
from 基础公共脚本.common_util import auto_fill_form, click_submit, click_cancel, close_input_null
from 数据核查.testUnit.check_scene_util import scene_check_index

def check_scene_add_defect(input_data=None, ui_expect=None):
    open_menu({'子系统名称': '反洗钱系统', '菜单名称': '数据核查/核查场景'})
    FE.button("新增场景").click()
    time.sleep(1)
    add_defect(input_data)
    click_submit()
    # 检查查询结果
    if re.search(r'不', list(ui_expect.values())[0], re.I):
        check_tips(ui_expect=ui_expect)
    elif re.search(r'提示', list(ui_expect.keys())[0], re.I):
        check_msg_box(ui_expect=ui_expect)
    else:
        check_table(input_data=None, ui_expect=ui_expect)

def check_scene_add_defect_cancel(input_data=None, ui_expect=None):
    open_menu({'子系统名称': '反洗钱系统', '菜单名称': '数据核查/核查场景'})
    FE.button("新增场景").click()
    time.sleep(1)
    add_defect(input_data)
    click_cancel()
    # 检查查询结果
    check_table_no_exist(input_data=None, ui_expect=ui_expect)

def check_scene_add_defect_contrary(input_data=None, ui_expect=None):
    open_menu({'子系统名称': '反洗钱系统', '菜单名称': '数据核查/核查场景'})
    FE.button("新增场景").click()
    time.sleep(1)
    add_defect(input_data)
    click_submit()
    # 检查查询结果
    # check_tips_msg( ui_expect=ui_expect)

def add_defect(input_data):
    text = None
    if input_data.get("缺失要素"):
        text = input_data.pop("缺失要素")
        print('text'+text)
    auto_fill_form("场景类型", input_data)
    tempList = text.split("&")
    if tempList[0]:
        scene_check_index("缺失要素", tempList[0], 1)
    else:
        close_input_null("缺失要素")
    if tempList[1]:
        scene_check_index("缺失要素", tempList[1], 2)
